Step 10: Query Distributed Index (Global Index)

TcaplusDB Client - Select Command (Query Global Indexes)

For TcaplusDB Client Instructions, see Document.

1. Function Descriptions

Query all qualified data according to the values of some global index fields specified by the user. It supports to query all field values or partial field values of the all data. If there are no matching records, an error will be returned.

Before querying a global index, the table must have been created with a global index. For the creation method, see Create Global Indexes.

Please note that the file name for saving query results cannot start with a number.

2. Initial Version

3.46.0

3. Command Syntax

select key1, key2, key3, value1, value2 [into result.csv] from table [where index_key1 = 1 and index_key2 = "abc"] [\P] [\G] [\S] [using tdr] [encode]
select * [into result.xml] from table [where index_key1 = 1 and index_key2 = "abc"] using tdr [\P];

Parameter description:

ParameterPB TableTDR TableRequired
tableTable nameTable nameYes
index_keyIndex field name. You can specify the value of partial index fieldsIndex field name. You can specify the value of partial index fieldsYes
key/valuefield namefield nameAt least one or *
\PPrint delay dataPrint delay dataNo
\GVertical printingVertical printingNo
\SRead data from copyRead data from copyNo. If not specified, it is the default to read data from the primary replica
\NDo not print field namesDo not print field namesNo. If not specified, it is the default to print field names
\AAppend query results to a fileAppend query results to a fileNo. If not specified, it is the default to overwrite the query results to a file
intoExport data to fileExport data to fileNo
using tdrDo not supportIf this parameter is required, it needs to specify the TDR file corresponding to the target table through the startup parameters at the time of starting the TcaplusDB Client.No
encodeNot supported (carriage return or invisible characters have been preprocessed)After specifying this parameter, the dump command will encode the string type field value containing carriage return characters or invisible characters into BASE64 before outputting.
Note: This parameter takes effect only when it is specified using tdr
No

4. Command Example

It is assumed that a global index has been created for the name and uname fields of the table. See Table Definition Example for table definition.

tcaplus> select * from test_table where name='testname' and uname='ab';
+------+------+----------+------+----+-----+
|gameid|itemid|name      |typeid|Data|uname|
+------+------+----------+------+----+-----+
|1234  |12323 |"testname"|0     |9   |"ab" |
+------+------+----------+------+----+-----+
1 records selectd, select time: 9802 us

tcaplus> select uname from test_table where name='testname' and uname='ab';
+------+------+----------+-----+
|gameid|itemid|name      |uname|
+------+------+----------+-----+
|1234  |12323 |"testname"|"ab" |
+------+------+----------+-----+
1 records selectd, select time: 9457 us

5. Common Errors

Refer to Common Errors.

[TDR Generic Table][C++ SDK] Interface Description for Querying Global Index.

[TDR Generic Table][Go SDK] Interface Description for Querying Global Index.

[PB Generic Table][C++ SDK] Interface Description for Querying Global Index.

[PB Generic Table][Go SDK] Interface Description for Querying Global Index.

[PB Generic Table][RESTFul API] Interface Description for Querying Global Index.